home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / hardware / blizkick / modules / softscsi.asm < prev    next >
Assembly Source File  |  1999-05-17  |  5KB  |  238 lines

  1. ; FILE: Source:modules/SoftSCSI.ASM          REV: 20 --- Softkick SCSI ROM
  2.  
  3. ;
  4. ; SoftSCSI -Module
  5. ; ~~~~~~~~~~~~~~~~
  6. ; This module will replace the SCSI (ep)rom (27C256) found from BLIZZARD
  7. ; turbo boards via software. Should work with 1230-IV, 1240-T/ERC and 1260.
  8. ;
  9. ; +--------------+------------------------
  10. ; |  1230-IV     |
  11. ; |  1240-T/ERC  |     A1234.ROM
  12. ; |  1260        |
  13. ; +--------------+------------------------
  14. ;
  15. ; The ROM file *must* be "DEVS:Modules/A1234.ROM".
  16. ; Note that this module requires lots of rom space (~20K), so you should
  17. ; use EXTRESBUF feature of BlizKick.
  18. ;
  19. ; Beta ROM file can be obtained from phase5's ftp server ftp.phase5.de,
  20. ; directory /pub/phase5/BETA/SCSI/.
  21. ;
  22. ; This module does the same thing as SoftSCSI
  23. ; (Aminet: util/boot/SoftSCSI.lha) by Gideon Zenz.
  24. ;
  25. ; Written by Harry Sintonen.
  26. ; This source code is Public Domain.
  27. ;
  28.  
  29.     incdir    "include:"        ; Some required...
  30.     include    "exec/types.i"
  31.     include    "exec/libraries.i"
  32.     include    "libraries/configvars.i"
  33.     include    "blizkickmodule.i"
  34.  
  35. _LVOOpenLibrary        EQU    -$228
  36. _LVOCloseLibrary    EQU    -$19E
  37.  
  38. _LVOOpen        EQU    -$1E
  39. _LVOClose        EQU    -$24
  40. _LVORead        EQU    -$2A
  41.  
  42. _LVOFindConfigDev    EQU    -$48
  43.  
  44. MODE_OLDFILE        EQU    1005
  45. OFFSET_BEGINNING    EQU    -1
  46. OFFSET_CURRENT        EQU    0
  47. OFFSET_END        EQU    1
  48.  
  49. call    MACRO
  50.     jsr    (_LVO\1,a6)
  51.     ENDM
  52.  
  53.  
  54. BLIZPROD    EQU    $2140
  55. XROM_BUFSIZE    EQU    32768
  56.  
  57.  
  58.     SECTION    PATCH,CODE
  59. _DUMMY_LABEL
  60.     BK_PTC
  61.  
  62. ; Code is run with following incoming parameters:
  63. ;
  64. ; a0=ptr to ROM start (buffer)    eg. $1DE087B8
  65. ; a1=ptr to ROM start (ROM)    eg. $00F80000 (do *not* access!)
  66. ; d0=ROM lenght in bytes    eg. $00080000
  67. ; a2=ptr to _FindResident routine (will search ROM buffer for resident tag):
  68. ;    CALL: jsr (a2)
  69. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to resident name
  70. ;     OUT: d0=ptr to resident (buf) or NULL
  71. ; a3=ptr to _InstallModule routine (can be used to plant a "module"):
  72. ;    CALL: jsr (a3)
  73. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to module, d6=dosbase
  74. ;     OUT: d0=success
  75. ; a4=ptr to _Printf routine (will dump some silly things (errormsg?) to stdout ;-)
  76. ;    CALL: jsr (a4)
  77. ;      IN: a0=FmtString, a1=Array (may be 0), d6=dosbase
  78. ;     OUT: -
  79. ; d6=dosbase, a6=execbase
  80. ;
  81. ; Code should return:
  82. ;
  83. ; d0=true if succeeded, false if failed.
  84. ; d1-d7/a0-a6 can be trashed. a7 *must* be preserved! ;-)
  85.  
  86.  
  87. ; NOTE: Kickstart *is* 2.0+
  88.  
  89.     cmp.w    #37,($C,a0)        ; Requires KS ROM V2.04+
  90.     bhs.b    .go
  91.     moveq    #0,d0
  92.     rts
  93.  
  94. .go    movem.l    d0/a0-a1,-(sp)
  95.     moveq    #0,d7
  96.  
  97.     lea    (_sscsi_name,pc),a1    ; _FindResident
  98.     jsr    (a2)
  99.     tst.l    d0
  100.     bne    .xit            ; Already installed!
  101.  
  102.     lea    (_ExpName,pc),a1
  103.     moveq    #37,d0
  104.     call    OpenLibrary
  105.     move.l    d0,d5
  106.     beq    .xit
  107.  
  108.     sub.l    a0,a0            ; BUG: was missing!
  109.     move.l    #BLIZPROD,d0        ; Requires 1230-IV, 1240 or 1260!
  110.     moveq    #$11,d1
  111.     exg    d5,a6
  112.     call    FindConfigDev
  113.     exg    d5,a6
  114.     move.l    d0,d2
  115.     move.l    d5,a1
  116.     call    CloseLibrary
  117.     tst.l    d2
  118.     beq    .berr            ; Need board!
  119.  
  120.     exg    d6,a6
  121.     lea    (_1200name,pc),a0
  122.     move.l    a0,d1
  123.     move.l    #MODE_OLDFILE,d2
  124.     call    Open
  125.     move.l    d0,d5
  126.     beq.b    .exitd            ; No file!
  127.  
  128.     lea    (_ROMImage,pc),a5    
  129.     move.l    d5,d1
  130.     move.l    a5,d2
  131.     moveq    #4,d3
  132.     call    Read
  133.     cmp.l    d0,d3
  134.     bne.b    .readerr        ; bad romfile!
  135.     cmp.l    #'XROM',(a5)
  136.     bne.b    .readerr        ; bad romfile!
  137.  
  138.     move.l    d5,d1
  139.     move.l    #XROM_BUFSIZE,d3    ; Read it!
  140.     call    Read
  141.     tst.l    d0
  142.     bmi.b    .readerr        ; bad romfile!
  143.     add.l    d0,_softscsi_module+bkm_ResTag+RT_ENDSKIP  ; magic... :)
  144.  
  145.     movem.l    (sp),d0/a0
  146.     lea    (_softscsi_module,pc),a1
  147.     exg    d6,a6            ; d6=dosbase !!
  148.     jsr    (a3)            ; _InstallModule
  149.     exg    d6,a6
  150.     tst.l    d0
  151.     beq.b    .installerr        ; Failed!
  152.  
  153.     moveq    #1,d7            ; All ok!
  154.  
  155. .readerr    move.l    d5,d1
  156.     call    Close
  157.  
  158. .exitd    exg    d6,a6
  159. .exit    move.l    d7,d0            ; Valid counter?
  160.     bne.b    .xit
  161.     lea    (_error1,pc),a0        ; a0=fmt
  162. .fail    pea    (_1200name,pc)
  163.     pea    (_header,pc)
  164.     move.l    sp,a1            ; a1=array
  165.     jsr    (a4)            ; Call _Printf
  166.     addq.l    #8,sp
  167.     moveq    #0,d0            ; Return fail
  168. .xit    lea    (3*4,sp),sp
  169.     rts
  170.  
  171. .berr    lea    (_error2,pc),a0
  172.     bra.b    .fail    
  173.  
  174.  
  175. .installerr    move.l    d5,d1
  176.     call    Close
  177.     exg    d6,a6
  178.     lea    (_error3,pc),a0        ; a0=fmt
  179.     bra.b    .fail    
  180.  
  181.  
  182. _1200name    dc.b    'DEVS:Modules/A1234.ROM',0
  183.  
  184. _header    dc.b    'SoftSCSI: ',0
  185. _error1    dc.b    '%sCouldn''t load "%s"!',10,0
  186. _error2    dc.b    '%sRequires BLIZZARD 1230-IV, 1240-T/ERC or 1260 turbo board.',10,0
  187. _error3    dc.b    '%sCouldn''t plant module! (increase EXTRESBUF)',10,0
  188.  
  189.     CNOP    0,4
  190. _softscsi_module
  191.  BK_MOD BKMF_SingleMode,_patch_end,(RTF_COLDSTART)<<24!37<<16!NT_UNKNOWN<<8!104,_sscsi_name,_sscsi_name,.SoftSCSI
  192.  
  193. ;  IN: d0=0, a0=0?, a6=execbase
  194. .SoftSCSI    movem.l    d0-a6,-(sp)
  195.     lea    (_ExpName,pc),a1
  196.     moveq    #37,d0
  197.     call    OpenLibrary
  198.     move.l    d0,d6
  199.     beq.b    .exit
  200.  
  201.     sub.l    a0,a0
  202.     move.l    #$2140,d0
  203.     moveq    #$11,d1
  204.     exg    d6,a6
  205.     call    FindConfigDev
  206.     exg    d6,a6
  207.     tst.l    d0
  208.     beq.b    .close
  209.  
  210.     move.l    d0,a0
  211.     move.l    (cd_Rom+er_Reserved0c,a0),a0    ; a0=DiagArea
  212.     lea    (14,a0),a1
  213.     move.l    (26,a1),a0
  214.     move.l    (30,a1),a3
  215.     lea    (34,a1),a4        ; a6=execbase
  216.     movem.l    d6/a6,-(sp)
  217.     bsr.b    _Code
  218.     movem.l    (sp)+,d6/a6
  219.  
  220. .close    move.l    d6,a1
  221.     call    CloseLibrary
  222.  
  223. .exit    movem.l    (sp)+,d0-a6
  224.     rts
  225.  
  226. _ExpName    dc.b    'expansion.library',0
  227. _sscsi_name    dc.b    'SoftSCSI',0
  228.     CNOP    0,8
  229. _ROMImage
  230. _Code
  231. _patch_end                    ; MUST be here!
  232.     ds.b    XROM_BUFSIZE
  233.  
  234.  
  235.     SECTION    VERSION,DATA
  236.  
  237.     dc.b    '$VER: SoftSCSI_MODULE 1.2 (10.3.97)',0
  238.